﻿@model Model.AppUserList
@{
    ViewBag.Title = "UserManage";
    Layout = "~/Views/Shared/_JQBaseLayOut.cshtml";
}
@using Model

@section JQscriptSection{
    <script type="text/javascript">
        $(document).ready(function () {
            InitGrid();

        });

        HandleDom.ClassTriggerClick("icon-add", function () {
            $('#hiddenUSERCELLID').val();
            $('#hiddenUserID').val();
            HandleDialog.OpenDialogByAdd('dlg', '添加用户库位关系', function () {
                HandleData.ClearForm('location');
                $('#showTxt').hide();;
                $('#showSelect').show();
                $('#cellNo').combobox('setValue', '0');
                $('#UserCode').combobox('setValue', '0');
                $('#warehHuseId').combobox('setValue', '0');


            });
        });

        HandleDom.ClassTriggerClick("icon-edit", function () {
            var row = HandleData.GetDataGridSelected("dg");
            edit(row);
        });

        HandleDom.ClassTriggerClick("icon-reload", function () {
            InitGrid();
        });

        HandleDom.ClassTriggerClick("icon-remove", function () {
            var ids = "";
            var rows = $('#dg').datagrid('getSelections');
            for (var i = 0; i < rows.length; i++) {
                ids = ids + rows[i].USERCELLID + ",";
            }

            $('#hiddenIDlist').val(ids);
            deleteDate();

        });

        //编辑
        function edit(row) {
            HandleData.ClearForm('location');
            HandleDialog.OpenDialog(row, 'dlg', '编辑用户库位关系', function () {
                $('#txtUserCode').attr("readonly", true);
                $('#showSelect').hide();
                HandleData.SetValueComboBox('cellNo', row.CELLNO);
              
                $('#txtUserCode').val(row.USERNAME);
                $('#txtRemark').val(row.REMARK);
                $('#hiddenUSERCELLID').val(row.USERCELLID);
                $('#hiddenUserID').val(row.USERID);


            });
        }

        function saveData(isClose) {
            HandleRequest.submitForm('location', '@Url.Action("SaveData", "UserManage")', function (data) {
                eval('data=' + data);
                if (data.success == true) {
                    layer.alert('执行成功!', 9);
                    InitGrid();
                    HandleDialog.CloseDialog('dlg');
                } else {
                    layer.msg(data.msg, 1);
                }

            });
        }

        function deleteDate() {
            HandleRequest.submitForm('location', '@Url.Action("Delete", "UserManage")', function (data) {
                  eval('data=' + data);
                  if (data.success == true) {
                      layer.alert('执行成功!', 9);
                      InitGrid();
                      HandleDialog.CloseDialog('dlg');
                  } else {
                      layer.msg(data.msg, 1);
                  }

              });
          }


        function InitGrid() {
            var txtSUSERNAME = $('#txtSUSERNAME').val();
            var txtSCELLNO = $('#txtSCELLNO').val();
            queryParams = {
                suserName: txtSUSERNAME,
                sCellno: txtSCELLNO
            }
            HandleData.InitDataGrid('dg', '/UserManage/InitJsonResult', 'toolbar', queryParams, 'USERCELLID', false, function (data) { },
                function (rowIndex, rowData) {//双击
                    edit(rowData);
                });
        }
    </script>
}

<body style="background-color: ButtonFace; font-size: 17px">
    <div class="easyui-panel" title="查询条件" style="height: 130px; padding: 5px; background: #fafafa; width: 1700px;">
        <form id="query" method="post">
            <table>
                <tr>
                    <td>用户:
                    </td>
                    <td>
                        <input id="txtSUSERNAME" name="txtSUSERNAME" style="width: 154px" />
                    </td>
                    <td>库位:
                    </td>
                    <td>
                        <input id="txtSCELLNO" name="txtSCELLNO" style="width: 154px" />
                    </td>
                    <td></td>
                    <td>
                        <a id="btnSerach" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search'" onclick="InitGrid()">查询</a>
                    </td>

                </tr>
            </table>
        </form>

    </div>
    <div style="min-height: 720px; width: 1700px;">
        <table id="dg" title="用户管理" style="min-height: 600px;">
            <thead>
                <tr>
                    <th data-options="field:'ck',checkbox:true"></th>
                    <th data-options="field:'USERCELLID',width:50">用户库位关联ID</th>
                    <th data-options="field:'USERID',width:50">用户ID</th>
                    <th data-options="field:'USERCODE',width:50">用户登录名</th>
                    <th data-options="field:'USERNAME',width:50">用户名称</th>
                    <th data-options="field:'LOOKUP',width:50">库位</th>
                    <th data-options="field:'CREATER',width:50">创建人</th>
                    <th data-options="field:'CREATEDATE',width:130,sortable:true,formatter: function (value, rowData, rowIndex) { return FormatData.formatDate(value);}">创建时间</th>
                    <th data-options="field:'EDITOR',width:30">修改人</th>
                    <th data-options="field:'EDITDATE',width:130,sortable:true,formatter: function (value, rowData, rowIndex) { return FormatData.formatDate(value);}">修改时间</th>
                    <th data-options="field:'REMARK',width:100">备注</th>
                </tr>
            </thead>
        </table>
    </div>
    <div id="dlg" class="easyui-dialog" style="width: 620px; height: 250px; top: 300px; left: 400px; padding: 2px"
        data-options="closed:true,buttons:'#dlg-buttons',modal:true">
        <form id="location" method="post">
            <table>
                <tr>
                    <td>登录名:
                    </td>
                    <td>
                        <input id="hiddenUSERCELLID" name="hiddenUSERCELLID" type="hidden" />
                        <input id="hiddenUserID" name="hiddenUserID" type="hidden" />
                        <input id="hiddenIDlist" name="hiddenIDlist" type="hidden" />
                        <div id="showTxt">
                            <input id="txtUserCode" name="txtUserCode" maxlength="255" style="width: 154px" />
                        </div>
                        <div id="showSelect">
                            <input id="UserCode" class="easyui-combobox" name="UserCode" style="width: 155px;" data-options="valueField:'USERID',textField:'USERNAME',url:'@Url.Action("UserList", "BaseData", new { })',editable:false">
                        </div>
                    </td>
                    <td>库位:
                    </td>
                    <td colspan="2">
                        <input id="cellNo" class="easyui-combobox" name="cellNo" style="width: 155px;" data-options="required:true,valueField:'FIELDVALUE',textField:'CELLNO',url:'@Url.Action("CellNoList", "BaseData", new { })',editable:false">
                    </td>
                </tr>
                <tr>
                    <td>备注:
                    </td>
                    <td colspan="4">
                        <input id="txtRemark" name="txtRemark" maxlength="255" style="width: 520px" />
                    </td>
                </tr>

                <tr>
                    <td colspan="5">
                        <a id="btnSave" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-save'" onclick="saveData(false)">保存</a>
                    </td>
                </tr>
            </table>
        </form>
    </div>
    @Html.Partial("~/Views/Shared/_PartialToolbar.cshtml", new Toolbar
{
    GridName = "dg",
    GridType = "datagrid",
    ToolbarName = "toolbar",
    FunctionModule = new Dictionary<string, List<FunctionModule>>()
    {
        {"Function",new List<FunctionModule>()
            {
              new FunctionModule(){Name = "Add",IsEnable =true },
              new FunctionModule(){Name = "Edit",IsEnable =true },
              new FunctionModule(){Name = "Remove",IsEnable =true },
              new FunctionModule(){Name = "Reload",IsEnable =false },
              new FunctionModule(){Name = "Collapse",IsEnable =false },
              new FunctionModule(){Name = "Exporter",IsEnable =true },
              
            }
        }
    }
})

</body>


